/**
 * 
 */
package com.firebird.oms.web.base;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.firebird.oms.exception.OmsRuntimeException;
import com.firebird.oms.user.UserDetails;
import com.firebird.oms.web.util.DwrAuthHelper;

/**
 * @author qiuxj
 * @date 2009-11-21
 *
 */
public class BaseDwr {
	
	protected Log logger = LogFactory.getLog(this.getClass());

	/**
	 * 获取session用户
	 * 
	 * @return 用户实例
	 */
	public UserDetails getCurrentUser() {
		Object ud = DwrAuthHelper.getUser();
		if (ud == null) {
			throw new OmsRuntimeException("登录超时或未登录系统,请重新登录");
		} else {
			return (UserDetails)ud;
		}
	}

	/**
	 * 获取登录ip
	 * 
	 * @return
	 */
	public String getIpAddress() {
		return DwrAuthHelper.getIpAddress();
	}
	
	/**
	 * 获取sessionID
	 * @return
	 */
	public String getSessionId() {
		return DwrAuthHelper.getSessionId();
	}
	
	
}
